library(ggplot2)
library(multiplot)
setwd("E:/5hmc_file/2_5hmc_yjp_bam/ASM/bayes_pvalue_beta0")
group1=c("X2B_X1T","M8_M7","M6_M5","M2_M1","M48_M47","M50_M49","M28_M27","M30_M29","M26_M25","M35_M36","M18_M17","M20_M19","M22_M21","M40_M39")
group2=c("DCf2_DCf1","DCg2_DCg1","DCh2_DCh1","DCi2_DCi1","DCm2_DCm1","JYS3T_JYS3","CCa2_CCa1","CCb2_CCb1","CCc2_CCc1","CCd2_CCd1","HCn2_HCn1","HCo2_HCo1","HCp2_HCp1","HCq2_HCq1")
sel=paste(group1,".bayes_p.txt",sep="")
i=14
file=read.table(sel[i],head=T,sep="\t")
fn=group2[i]
norm.n=unlist(strsplit(fn,"_"))[1]
tumor.n=unlist(strsplit(fn,"_"))[2]

r=cor.test(file$normal_reads1,file$tumor_reads1,method = "pearson")
p=as.numeric(format(r$p.value, digits = 3))
rr=as.numeric(format(r$estimate, digits = 3))

p8=ggplot(file,aes(normal_reads1,tumor_reads1))+geom_point(alpha=0.6)+
  labs(y=tumor.n,x=norm.n,title="")+
  theme_classic(base_size = 18)+annotate(x=70,y=10,label=paste("r = ",rr,sep=""),geom ="text" ,color="red",size=5)

layout <- matrix(c(1, 2, 3, 4,5,6,7,8), nrow = 2,byrow = T)

multiplot(plotlist=list(p1,p2,p3,p4,p5,p6,p7,p8),layout=layout)

fileMF=paste("Variant.allele.counts.pearson.correlation/",fn,".pdf",sep="")
pdf(fileMF,width = 5.5,height = 5)
print(p)
dev.off()
